﻿using System;

class FirstBiggerElement
{
    //Exercise 6.
    //Write a method that returns the index of the first element in array that is bigger than its neighbors, 
    //or -1, if there’s no such element.
    //Use the method from the previous exercise.
    //Sample:  int[] array = { 4, 5, 1, 4, 2, 5, 8 };

    static void Main()
    {
        int[] array = { 4, 3, 1, 4, 10, 15, 28 };
        
        CompareIntegers(array);

        Console.WriteLine("The index is {0}", CompareIntegers(array));
       
    }
    private static int CompareIntegers(int[] array)
    {
        for (int i = 1; i < array.Length - 1; i++)
        {
            if (array[i] > array[i + 1] && array[i] > array[i - 1])
            {
                return i;
            }
        }
        return -1;        
         
    }

   
}

